package cn.edu.hunau.java.week01.day04;

import org.junit.Test;

import java.util.Arrays;
import java.util.Scanner;

public class ArraySort02Test {
    @Test
    public void test01() {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[10];
        int count = 0;
        while (true) {
            int num=sc.nextInt();
            if (num <= 0) {
                break;
            }
            if (count >= arr.length) {
                int[] temp = new int[arr.length * 2];
                System.arraycopy(arr, 0, temp, 0, arr.length);
                arr = temp;
            }
            arr[count] = num;
            count++;
        }
        System.out.println("有效数据个数:" + count);
        int[] result = new int[count];
        System.arraycopy(arr,0,result,0,count);
        System.out.println(Arrays.toString(result));
    }
}

